home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 December / PCWorld_2007-12_cd.bin / domacnost a kancelar / autoit / autoit-v3-setup.exe / Include / Misc.au3 < prev    next >
Encoding:
Text File  |  2007-09-08  |  20.9 KB  |  534 lines

  1. #include-once
  2. ; ------------------------------------------------------------------------------
  3. ;
  4. ; AutoIt Version: 3.1.1++
  5. ; Language:       English
  6. ; Description:    Functions that assist with Common Dialogs.
  7. ;
  8. ; ------------------------------------------------------------------------------
  9. ; Color Dialog constants
  10. Global Const $CC_ANYCOLOR = 0x100
  11. Global Const $CC_FULLOPEN = 0x2
  12. Global Const $CC_RGBINIT = 0x1
  13. ; Font Dialog constants
  14. Global Const $CF_EFFECTS = 0x100
  15. Global Const $CF_PRINTERFONTS = 0x2
  16. Global Const $CF_SCREENFONTS = 0x1
  17. Global Const $CF_NOSCRIPTSEL = 0x800000
  18. Global Const $CF_INITTOLOGFONTSTRUCT = 0x40
  19. Global Const $DEFAULT_PITCH = 0
  20. Global Const $FF_DONTCARE = 0
  21. Global Const $LOGPIXELSX = 88
  22. ;===============================================================================
  23. ;
  24. ; Description:            _ChooseColor
  25. ; Parameter(s):            $i_ReturnType - Optional: determines return type
  26. ;                                $i_colorref - Optional: default selected Color
  27. ;                                $i_refType - Optional: Type of $i_colorref passed in
  28. ;                                $h_wnd_owner - Optional: Handle of owner window
  29. ; Requirement:            None
  30. ; Return Value(s):    Returns COLORREF rgbcolor if $i_refType = 0 (default)
  31. ;                            Returns Hex RGB value if $i_refType = 1
  32. ;                            Returns Hex BGR Color if $i_refType = 2
  33. ;                            if error occurs, @error is set
  34. ; User CallTip:        _ChooseColor([$i_ReturnType = 0[, $i_colorref = 0[, $i_refType=0[, $h_wnd_owner]]]]) Creates a Color dialog box that enables the user to select a color. (required: <Misc.au3>)
  35. ; Author(s):            Gary Frost (custompcs at charter dot net)
  36. ; Note(s):                $i_ReturnType = 0 then COLORREF rgbcolor is returned (default)
  37. ;                            $i_ReturnType = 1 then Hex BGR Color is returned
  38. ;                            $i_ReturnType = 2 Hex RGB Color is returned
  39. ;
  40. ;                            $i_colorref = 0 (default)
  41. ;
  42. ;                            $i_refType = 0 then $i_colorref is COLORREF rgbcolor value (default)
  43. ;                            $i_refType = 1 then $i_colorref is BGR hex value
  44. ;                            $i_refType = 2 then $i_colorref is RGB hex value
  45. ;
  46. ;===============================================================================
  47. Func _ChooseColor($i_ReturnType = 0, $i_colorref = 0, $i_refType = 0, $h_wnd_owner = 0)
  48. ;~ typedef struct {
  49. ;~     DWORD lStructSize;
  50. ;~     HWND hwndOwner;
  51. ;~     HWND hInstance;
  52. ;~     COLORREF rgbResult;
  53. ;~     COLORREF *lpCustColors;
  54. ;~     DWORD Flags;
  55. ;~     LPARAM lCustData;
  56. ;~     LPCCHOOKPROC lpfnHook;
  57. ;~     LPCTSTR lpTemplateName;
  58. ;~ } CHOOSECOLOR, *LPCHOOSECOLOR;
  59.     Local $custcolors = "int[16]"
  60.     Local $struct = "dword;int;int;int;ptr;dword;int;ptr;ptr"
  61.     Local $p = DllStructCreate($struct)
  62.     If @error Then
  63.         ;MsgBox(0,"","Error in DllStructCreate " & @error);
  64.         SetError(-1)
  65.         Return -1
  66.     EndIf
  67.     Local $cc = DllStructCreate($custcolors)
  68.     If @error Then
  69.         ; MsgBox(0,"","Error in DllStructCreate " & @error);
  70.         ;        DllStructDelete ($p)
  71.         SetError(-2)
  72.         Return -1
  73.     EndIf
  74.     If ($i_refType == 1) Then
  75.         $i_colorref = Int($i_colorref)
  76.     ElseIf ($i_refType == 2) Then
  77.         $i_colorref = Hex(String($i_colorref), 6)
  78.         $i_colorref = '0x' & StringMid($i_colorref, 5, 2) & StringMid($i_colorref, 3, 2) & StringMid($i_colorref, 1, 2)
  79.     EndIf
  80.     DllStructSetData($p, 1, DllStructGetSize($p))
  81.     DllStructSetData($p, 2, $h_wnd_owner)
  82.     DllStructSetData($p, 4, $i_colorref)
  83.     DllStructSetData($p, 5, DllStructGetPtr($cc))
  84.     DllStructSetData($p, 6, BitOR($CC_ANYCOLOR, $CC_FULLOPEN, $CC_RGBINIT))
  85.     Local $ret = DllCall("comdlg32.dll", "long", "ChooseColor", "ptr", DllStructGetPtr($p))
  86.     If ($ret[0] == 0) Then
  87.         ; user selected cancel or struct settings incorrect
  88.         ;        DllStructDelete ($p)
  89.         ;        DllStructDelete ($cc)
  90.         SetError(-3)
  91.         Return -1
  92.     EndIf
  93.     Local $color_picked = DllStructGetData($p, 4)
  94.     ;    DllStructDelete ($p)
  95.     ;    DllStructDelete ($cc)
  96.     If ($i_ReturnType == 1) Then
  97.         ; return Hex BGR Color
  98.         Return '0x' & Hex(String($color_picked), 6)
  99.     ElseIf ($i_ReturnType == 2) Then
  100.         ; return Hex RGB Color
  101.         $color_picked = Hex(String($color_picked), 6)
  102.         Return '0x' & StringMid($color_picked, 5, 2) & StringMid($color_picked, 3, 2) & StringMid($color_picked, 1, 2)
  103.     ElseIf ($i_ReturnType == 0) Then
  104.         Return $color_picked
  105.     Else
  106.         SetError(-4)
  107.         Return -1
  108.     EndIf
  109. EndFunc   ;==>_ChooseColor
  110. ;===============================================================================
  111. ;
  112. ; Description:            _ChooseFont
  113. ; Parameter(s):        $s_FontName - Optional: Default font name
  114. ;                            $i_size - Optional: pointsize of font
  115. ;                            $i_colorref - Optional: COLORREF rgbColors
  116. ;                            $i_FontWeight - Optional: Font Weight
  117. ;                            $i_Italic - Optional: Italic
  118. ;                            $i_Underline - Optional: Underline
  119. ;                            $i_Strikethru - Optional: Strikethru
  120. ;                            $h_wnd_owner - Optional: Handle of owner window
  121. ; Requirement:            None.
  122. ; Return Value(s):    Returns Array, $array[0] contains the number of elements
  123. ;                            if error occurs, @error is set
  124. ; User CallTip:        _ChooseFont([$s_FontName = "Courier New"[, $i_size = 10[, $i_colorref = 0[, $i_FontWeight = 0[, $i_Italic= 0[, $i_Underline = [0, $i_Strikethru = 0[, $h_wnd_owner]]]]]]]) Creates a Font dialog box that enables the user to choose attributes for a logical font. (required: <Misc.au3>)
  125. ; Author(s):            Gary Frost (custompcs at charter dot net)
  126. ; Note(s):                $array[1] - attributes = BitOr of italic:2, undeline:4, strikeout:8
  127. ;                            $array[2] - fontname
  128. ;                            $array[3] - font size = point size
  129. ;                            $array[4] - font weight = = 0-1000
  130. ;                            $array[5] - COLORREF rgbColors
  131. ;                            $array[6] - Hex BGR Color
  132. ;                            $array[7] - Hex RGB Color
  133. ;
  134. ;===============================================================================
  135. Func _ChooseFont($s_FontName = "Courier New", $i_size = 10, $i_colorref = 0, $i_FontWeight = 0, $i_Italic = 0, $i_Underline = 0, $i_Strikethru = 0, $h_wnd_owner = 0)
  136. ;~ typedef struct {
  137. ;~     DWORD lStructSize;
  138. ;~     HWND hwndOwner;
  139. ;~     HDC hDC;
  140. ;~     LPLOGFONT lpLogFont;
  141. ;~     INT iPointSize;
  142. ;~     DWORD Flags;
  143. ;~     COLORREF rgbColors;
  144. ;~     LPARAM lCustData;
  145. ;~     LPCFHOOKPROC lpfnHook;
  146. ;~     LPCTSTR lpTemplateName;
  147. ;~     HINSTANCE hInstance;
  148. ;~     LPTSTR lpszStyle;
  149. ;~     WORD nFontType;
  150. ;~     INT nSizeMin;
  151. ;~     INT nSizeMax;
  152. ;~ } CHOOSEFONT, *LPCHOOSEFONT;
  153. ;~ typedef struct tagLOGFONT {
  154. ;~   LONG lfHeight;
  155. ;~   LONG lfWidth;
  156. ;~   LONG lfEscapement;
  157. ;~   LONG lfOrientation;
  158. ;~   LONG lfWeight;
  159. ;~   BYTE lfItalic;
  160. ;~   BYTE lfUnderline;
  161. ;~   BYTE lfStrikeOut;
  162. ;~   BYTE lfCharSet;
  163. ;~   BYTE lfOutPrecision;
  164. ;~   BYTE lfClipPrecision;
  165. ;~   BYTE lfQuality;
  166. ;~   BYTE lfPitchAndFamily;
  167. ;~   TCHAR lfFaceName[LF_FACESIZE]; 32 chars max
  168. ;~ } LOGFONT, *PLOGFONT;
  169.     Local $ret = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", 0, "long", $LOGPIXELSX)
  170.     If ($ret[0] == -1) Then
  171.         SetError(-3)
  172.         Return -1
  173.     EndIf
  174.     Local $lfHeight = Round(($i_size * $ret[2]) / 72, 0)
  175.     Local $logfont = "int;int;int;int;int;byte;byte;byte;byte;byte;byte;byte;byte;char[32]"
  176.     Local $struct = "dword;int;int;ptr;int;dword;int;int;ptr;ptr;int;ptr;dword;int;int"
  177.     Local $p = DllStructCreate($struct)
  178.     If @error Then
  179.         ;MsgBox(0,"","Error in DllStructCreate " & @error);
  180.         SetError(-1)
  181.         Return -1
  182.     EndIf
  183.     Local $lf = DllStructCreate($logfont)
  184.     If @error Then
  185.         ; MsgBox(0,"","Error in DllStructCreate " & @error);
  186.         ;        DllStructDelete ($p)
  187.         SetError(-2)
  188.         Return -1
  189.     EndIf
  190.     DllStructSetData($p, 1, DllStructGetSize($p))
  191.     DllStructSetData($p, 2, $h_wnd_owner)
  192.     DllStructSetData($p, 4, DllStructGetPtr($lf))
  193.     DllStructSetData($p, 5, $i_size)
  194.     DllStructSetData($p, 6, BitOR($CF_SCREENFONTS, $CF_PRINTERFONTS, $CF_EFFECTS, $CF_INITTOLOGFONTSTRUCT, $CF_NOSCRIPTSEL))
  195.     DllStructSetData($p, 7, $i_colorref)
  196.     DllStructSetData($p, 13, 0)
  197.     DllStructSetData($lf, 1, $lfHeight + 1)
  198.     DllStructSetData($lf, 5, $i_FontWeight)
  199.     DllStructSetData($lf, 6, $i_Italic)
  200.     DllStructSetData($lf, 7, $i_Underline)
  201.     DllStructSetData($lf, 8, $i_Strikethru)
  202.     DllStructSetData($lf, 14, $s_FontName)
  203.     $ret = DllCall("comdlg32.dll", "long", "ChooseFont", "ptr", DllStructGetPtr($p))
  204.     If ($ret[0] == 0) Then
  205.         ; user selected cancel or struct settings incorrect
  206.         ;        DllStructDelete ($p)
  207.         ;        DllStructDelete ($lf)
  208.         SetError(-3)
  209.         Return -1
  210.     EndIf
  211.     Local $fontname = DllStructGetData($lf, 14)
  212.     If (StringLen($fontname) == 0 And StringLen($s_FontName) > 0) Then
  213.         $fontname = $s_FontName
  214.     EndIf
  215.     Local $italic = 0
  216.     Local $underline = 0
  217.     Local $strikeout = 0
  218.     If (DllStructGetData($lf, 6)) Then
  219.         $italic = 2
  220.     EndIf
  221.     If (DllStructGetData($lf, 7)) Then
  222.         $underline = 4
  223.     EndIf
  224.     If (DllStructGetData($lf, 8)) Then
  225.         $strikeout = 8
  226.     EndIf
  227.     Local $attributes = BitOR($italic, $underline, $strikeout)
  228.     Local $size = DllStructGetData($p, 5) / 10
  229.     Local $weight = DllStructGetData($lf, 5)
  230.     Local $colorref = DllStructGetData($p, 7)
  231.     ;    DllStructDelete ($p)
  232.     ;    DllStructDelete ($lf)
  233.     Local $color_picked = Hex(String($colorref), 6)
  234.     Return StringSplit($attributes & "," & $fontname & "," & $size & "," & $weight & "," & $colorref & "," & '0x' & $color_picked & "," & '0x' & StringMid($color_picked, 5, 2) & StringMid($color_picked, 3, 2) & StringMid($color_picked, 1, 2), ",")
  235. EndFunc   ;==>_ChooseFont
  236. ;===============================================================================
  237. ;
  238. ; Description:      Copy Files to Clipboard Like Explorer does
  239. ; Parameter(s):     $sFile      - Full Path to File(s)
  240. ;                   $sSeperator - Seperator for multiple Files, Default = '|'
  241. ; Requirement(s):   v3.1.1.122+
  242. ; Return Value(s):  On Success - True
  243. ;                   On Failure - False and
  244. ;                                    Sets @ERROR to:    1 - Unable to Open Clipboard
  245. ;                                                    2 - Unable to Empty Cipboard
  246. ;                                                    3 - GlobalAlloc Failed
  247. ;                                                    4 - GlobalLock Failed
  248. ;                                                    5 - Unable to Create H_DROP
  249. ;                                                    6 - Unable to Update Clipboard
  250. ;                                                    7 - Unable to Close Clipboard
  251. ;                                                    8 - GlobalUnlock Failed
  252. ; Author(s):        Piccaso (Florian Fida)
  253. ; Note(s):
  254. ;
  255. ;===============================================================================
  256. Func _ClipPutFile($sFile, $sSeperator = "|")
  257.     Local $vDllCallTmp, $nGlobMemSize, $hGlobal, $DROPFILES, $i, $hLock
  258.     Local $GMEM_MOVEABLE = 0x0002, $CF_HDROP = 15
  259.     $sFile = $sFile & $sSeperator & $sSeperator
  260.     $nGlobMemSize = StringLen($sFile) + 20 ; 20 = size of DROPFILES whitout buffer
  261.     $vDllCallTmp = DllCall("user32.dll", "int", "OpenClipboard", "hwnd", 0)
  262.     If @error Or $vDllCallTmp[0] = 0 Then
  263.         SetError(1)
  264.         Return False
  265.     EndIf
  266.     $vDllCallTmp = DllCall("user32.dll", "int", "EmptyClipboard")
  267.     If @error Or $vDllCallTmp[0] = 0 Then
  268.         SetError(2)
  269.         Return False
  270.     EndIf
  271.     $vDllCallTmp = DllCall("kernel32.dll", "long", "GlobalAlloc", "int", $GMEM_MOVEABLE, "int", $nGlobMemSize)
  272.     If @error Or $vDllCallTmp[0] < 1 Then
  273.         SetError(3)
  274.         Return False
  275.     EndIf
  276.     $hGlobal = $vDllCallTmp[0]
  277.     $vDllCallTmp = DllCall("kernel32.dll", "long", "GlobalLock", "long", $hGlobal)
  278.     If @error Or $vDllCallTmp[0] < 1 Then
  279.         SetError(4)
  280.         Return False
  281.     EndIf
  282.     $hLock = $vDllCallTmp[0]
  283.     $DROPFILES = DllStructCreate("dword;ptr;int;int;int;char[" & StringLen($sFile) & "]", $hLock)
  284.     If @error Then
  285.         SetError(5)
  286.         Return False
  287.     EndIf
  288.     DllStructSetData($DROPFILES, 1, DllStructGetSize($DROPFILES) - StringLen($sFile))
  289.     DllStructSetData($DROPFILES, 2, 0)
  290.     DllStructSetData($DROPFILES, 3, 0)
  291.     DllStructSetData($DROPFILES, 4, 0)
  292.     DllStructSetData($DROPFILES, 5, 0)
  293.     DllStructSetData($DROPFILES, 6, $sFile)
  294.     For $i = 1 To StringLen($sFile)
  295.         If DllStructGetData($DROPFILES, 6, $i) = Asc($sSeperator) Then DllStructSetData($DROPFILES, 6, 0, $i)
  296.     Next
  297.     $vDllCallTmp = DllCall("user32.dll", "long", "SetClipboardData", "int", $CF_HDROP, "long", $hGlobal)
  298.     If @error Or $vDllCallTmp[0] < 1 Then
  299.         SetError(6)
  300.         $DROPFILES = 0
  301.         Return False
  302.     EndIf
  303.     $vDllCallTmp = DllCall("user32.dll", "int", "CloseClipboard")
  304.     If @error Or $vDllCallTmp[0] = 0 Then
  305.         SetError(7)
  306.         $DROPFILES = 0
  307.         Return False
  308.     EndIf
  309.     $vDllCallTmp = DllCall("kernel32.dll", "int", "GlobalUnlock", "long", $hGlobal)
  310.     If @error Then
  311.         SetError(8)
  312.         $DROPFILES = 0
  313.         Return False
  314.     EndIf
  315.     $vDllCallTmp = DllCall("kernel32.dll", "int", "GetLastError")
  316.     If $vDllCallTmp = 0 Then
  317.         $DROPFILES = 0
  318.         SetError(8)
  319.         Return False
  320.     Else
  321.         $DROPFILES = 0
  322.         Return True
  323.     EndIf
  324. EndFunc   ;==>_ClipPutFile
  325. ;
  326. ;===============================================================================
  327. ;
  328. ; Function Name:    _Iif()
  329. ; Description:      Perform a boolean test within an expression.
  330. ; Parameter(s):     $f_Test     - Boolean test.
  331. ;                   $v_TrueVal  - Value to return if $f_Test is true.
  332. ;                   $v_FalseVal - Value to return if $f_Test is false.
  333. ; Requirement(s):   None.
  334. ; Return Value(s):  One of $v_TrueVal or $v_FalseVal.
  335. ; Author(s):        Dale (Klaatu) Thompson
  336. ;
  337. ;===============================================================================
  338. Func _Iif($f_Test, $v_TrueVal, $v_FalseVal)
  339.     If $f_Test Then
  340.         Return $v_TrueVal
  341.     Else
  342.         Return $v_FalseVal
  343.     EndIf
  344. EndFunc   ;==>_Iif
  345. ;===============================================================================
  346. ;
  347. ; Description:    _MouseTrap
  348. ; Parameter(s):    $i_left - Left coord
  349. ;                 $i_top - Top coord
  350. ;                 $i_right - Right coord
  351. ;                 $i_bottom - Bottom coord
  352. ; User CallTip:   _MouseTrap([$i_left = 0[, $i_top = 0[, $i_right = 0[, $i_bottom = 0]]]]) Confine the Mouse Cursor to specified coords. (required: <Misc.au3>)
  353. ; Author(s):      Gary Frost (custompcs at charter dot net)
  354. ; Note(s):        Use _MouseTrap() with no params to release the Mouse Cursor
  355. ;
  356. ;===============================================================================
  357. Func _MouseTrap($i_left = 0, $i_top = 0, $i_right = 0, $i_bottom = 0)
  358.     Local $av_ret
  359.     If @NumParams == 0 Then
  360.         $av_ret = DllCall("user32.dll", "int", "ClipCursor", "int", 0)
  361.     Else
  362.         If @NumParams == 2 Then
  363.             $i_right = $i_left + 1
  364.             $i_bottom = $i_top + 1
  365.         EndIf
  366.         Local $Rect = DllStructCreate("int;int;int;int")
  367.         If @error Then Return 0
  368.         DllStructSetData($Rect, 1, $i_left)
  369.         DllStructSetData($Rect, 2, $i_top)
  370.         DllStructSetData($Rect, 3, $i_right)
  371.         DllStructSetData($Rect, 4, $i_bottom)
  372.         $av_ret = DllCall("user32.dll", "int", "ClipCursor", "ptr", DllStructGetPtr($Rect))
  373.         ;        DllStructDelete($Rect)
  374.     EndIf
  375.     Return $av_ret[0]
  376. EndFunc   ;==>_MouseTrap
  377. ;===============================================================================
  378. ;
  379. ; Description:    _Singleton
  380. ; Parameter(s):    $occurenceName
  381. ;               $flag
  382. ; User CallTip:   _Singleton($occurenceName [,$flag = 0]) Check if no other occurence is running. (required: <Misc.au3>)
  383. ; Return Value(s):  if $flag = 1
  384. ; Author(s):      Valik
  385. ;
  386. ;===============================================================================
  387. Func _Singleton($occurenceName, $flag = 0)
  388.     Local $ERROR_ALREADY_EXISTS = 183
  389.     $occurenceName = StringReplace($occurenceName, "\", "") ; to avoid error
  390.     ;    Local $handle = DllCall("kernel32.dll", "int", "CreateSemaphore", "int", 0, "long", 1, "long", 1, "str", $occurenceName)
  391.     Local $handle = DllCall("kernel32.dll", "int", "CreateMutex", "int", 0, "long", 1, "str", $occurenceName)
  392.     Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
  393.     If $lastError[0] = $ERROR_ALREADY_EXISTS Then
  394.         If $flag = 0 Then
  395.             Exit -1
  396.         Else
  397.             SetError($lastError[0])
  398.             Return 0
  399.         EndIf
  400.     EndIf
  401.     Return $handle[0]
  402. EndFunc   ;==>_Singleton
  403. ;
  404. ;===============================================================================
  405. ;
  406. ; Description:    _IsPressed
  407. ; Parameter(s):    $s_hexKey - key to check for
  408. ;                        $v_dll = Handle to dll or default to user32.dll
  409. ;
  410. ; User CallTip:   _IsPressed($s_hexKey[, $v_dll = 'user32.dll']) Check if key has been pressed. (required: <Misc.au3>)
  411. ; Return Value(s):  1 if true
  412. ;                            0 if false
  413. ; Author(s):      ezzetabi and Jon
  414. ;
  415. ;===============================================================================
  416. Func _IsPressed($s_hexKey, $v_dll = 'user32.dll')
  417.     ; $hexKey must be the value of one of the keys.
  418.     ; _Is_Key_Pressed will return 0 if the key is not pressed, 1 if it is.
  419.     Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey)
  420.     If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
  421.     Return 0
  422. EndFunc   ;==>_IsPressed
  423. ;
  424. ;===============================================================================
  425. ;
  426. ; Description:    _SendMessage
  427. ; Parameter(s): hwnd - window/control handle
  428. ;                  msg    - message to send to control (number)
  429. ;                  wParam - Specifies additional message-specific information (Optional: Default 0)
  430. ;                  lParam - Specifies additional message-specific information (Optional: Default 0)
  431. ;                  return - what to return (Optional: Default 0)
  432. ;                  wParam Type    - Specifies what type of additional information (Optional: Default "int")
  433. ;                  lParam Type    - Specifies what type of additional information (Optional: Default "int")
  434. ;
  435. ; User CallTip:   _SendMessage(hWnd, msg[, wParam = 0[, lParam = 0[, return = 0[, wParam Type = "int"[, lParam Type = "int"]]]]]) Wrapper for commonly used Dll Call. (required: <Misc.au3>)
  436. ; Return Value(s):
  437. ;    Success - User selected value from the DllCall() result.
  438. ;                     return = 0 thru 4 corresponds to the parameter of the _SendMessage Wrapper
  439. ;                     return < 0 or > 4 returns array same as DllCall
  440. ;    Failure - Sets @error if DllCall() fails.
  441. ; Author(s):      Valik
  442. ;
  443. ;===============================================================================
  444. Func _SendMessage($h_hWnd, $i_msg, $wParam = 0, $lParam = 0, $i_r = 0, $s_t1 = "int", $s_t2 = "int")
  445.     Local $a_ret = DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_hWnd, "int", $i_msg, $s_t1, $wParam, $s_t2, $lParam)
  446.     If @error Then Return SetError(@error, @extended, "")
  447.     If $i_r >= 0 And $i_r <= 4 Then Return $a_ret[$i_r]
  448.     Return $a_ret
  449. EndFunc   ;==>_SendMessage
  450.  
  451. ;===============================================================================
  452. ;
  453. ; Description:    _IsClassName
  454. ; Parameter(s):      $h_hWnd - control ID/Handle
  455. ;
  456. ; User CallTip:   _IsClassName($h_hWnd, $s_ClassName) Check ClassName of the control. (required: <Misc.au3>)
  457. ; Return Value(s):
  458. ;    Success - 1.
  459. ;    Failure - Sets @error and returns 0.
  460. ; Author(s):            Gary Frost (custompcs at charter dot net)
  461. ;
  462. ;===============================================================================
  463. Func _IsClassName($h_hWnd, $s_ClassName)
  464.     If Not IsHWnd($h_hWnd) Then $h_hWnd = GUICtrlGetHandle($h_hWnd)
  465.     Local $aResult = DllCall("user32.dll", "int", "GetClassNameA", "hwnd", $h_hWnd, "str", "", "int", 256)
  466.     If @error Then Return SetError(@error, @error, "")
  467.     If IsArray($aResult) Then
  468.         If StringUpper(StringMid($aResult[2], 1, StringLen($s_ClassName))) = StringUpper($s_ClassName) Then
  469.             Return 1
  470.         Else
  471.             Return 0
  472.         EndIf
  473.     Else
  474.         Return SetError(-1, -1, 0)
  475.     EndIf
  476. EndFunc   ;==>_IsClassName
  477.  
  478. ; ===================================================================
  479. ; Description:    _VersionCompare
  480. ; Parameters:
  481. ;    $sVersion1 - IN - The first version.
  482. ;    $sVersion2 - IN - The second version.
  483. ;
  484. ; User CallTip:   _VersionCompare($sVersion1, $sVersion2) Compares two file versions for equality. (required: <Misc.au3>)
  485. ; Return Value(s):
  486. ;    Success - 0 - Both versions equal
  487. ;              1 - Version 1 greater
  488. ;             -1 - Version 2 greater.
  489. ;                  @extended can be set as follows:  0 - Numeric comparison; 1 - String comparison
  490. ;    Failure - @error will be set in the event of a catasrophic error.
  491. ; Author(s):      Valik
  492. ; Note(s):        This will try to use a numerical comparison but fall back on
  493. ;                  a lexicographical comparison.  See @extended for details about which type was performed.
  494. ;
  495. ; ===================================================================
  496. Func _VersionCompare($sVersion1, $sVersion2)
  497.     If $sVersion1 = $sVersion2 Then Return 0
  498.     Local $sep = "."
  499.     If StringInstr($sVersion1, $sep) = 0 Then $sep = ","
  500.     Local $aVersion1 = StringSplit($sVersion1, $sep)
  501.     Local $aVersion2 = StringSplit($sVersion2, $sep)
  502.     If UBound($aVersion1) <> UBound($aVersion2) Or UBound($aVersion1) = 0 Then
  503.         ; Compare as strings
  504.         SetExtended(1)
  505.         If $sVersion1 > $sVersion2 Then
  506.             Return 1
  507.         ElseIf $sVersion1 < $sVersion2 Then
  508.             Return -1
  509.         EndIf
  510.     Else
  511.         For $i = 1 To UBound($aVersion1)-1
  512.             ; Compare this segment as numbers
  513.             If StringIsDigit($aVersion1[$i]) And StringIsDigit($aVersion2[$i]) Then
  514.                 If Number($aVersion1[$i]) > Number($aVersion2[$i]) Then
  515.                     Return 1
  516.                 ElseIf Number($aVersion1[$i]) < Number($aVersion2[$i]) Then
  517.                     Return -1
  518.                 EndIf
  519.             Else    ; Compare the segment as strings
  520.                 SetExtended(1)
  521.                 If $aVersion1[$i] > $aVersion2[$i] Then
  522.                     Return 1
  523.                 ElseIf $aVersion1[$i] < $aVersion2[$i] Then
  524.                     Return -1
  525.                 EndIf
  526.             EndIf
  527.         Next
  528.     EndIf
  529.     ; This point should never be reached
  530.     SetError(2)
  531.     Return 0
  532. EndFunc    ; _VersionCompare()
  533.